home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC_Samples / chatsrvr / chatsrvr.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  3.8 KB  |  156 lines

  1. // chatsrvr.cpp : Defines the class behaviors for the application.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1999 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "chatsrvr.h"
  15.  
  16. #include "mainfrm.h"
  17. #include "srvrdoc.h"
  18. #include "srvrvw.h"
  19.  
  20. #ifdef _DEBUG
  21. #undef THIS_FILE
  22. static char BASED_CODE THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CServerApp
  28.  
  29. BEGIN_MESSAGE_MAP(CServerApp, CWinApp)
  30.     //{{AFX_MSG_MAP(CServerApp)
  31.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  32.         // NOTE - the ClassWizard will add and remove mapping macros here.
  33.         //    DO NOT EDIT what you see in these blocks of generated code!
  34.     //}}AFX_MSG_MAP
  35.     // Standard file based document commands
  36.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  37.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  38. END_MESSAGE_MAP()
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CServerApp construction
  42.  
  43. CServerApp::CServerApp()
  44. {
  45. }
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // The one and only CServerApp object
  49.  
  50. CServerApp theApp;
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CServerApp initialization
  54.  
  55. BOOL CServerApp::InitInstance()
  56. {
  57.     if (!AfxSocketInit())
  58.     {
  59.         AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
  60.         return FALSE;
  61.     }
  62.  
  63.     // Standard initialization
  64.     // If you are not using these features and wish to reduce the size
  65.     //  of your final executable, you should remove from the following
  66.     //  the specific initialization routines you do not need.
  67.  
  68.     // Initialize static members of CSocketThread
  69.  
  70. #if !defined(_WIN32_WCE)
  71.     Enable3dControls();
  72. #endif
  73.  
  74.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  75.  
  76.     // Register the application's document templates.  Document templates
  77.     //  serve as the connection between documents, frame windows and views.
  78.  
  79.     CSingleDocTemplate* pDocTemplate;
  80.     pDocTemplate = new CSingleDocTemplate(
  81.         IDR_MAINFRAME,
  82.         RUNTIME_CLASS(CServerDoc),
  83.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  84.         RUNTIME_CLASS(CServerView));
  85.     AddDocTemplate(pDocTemplate);
  86.  
  87.     // create a new (empty) document
  88.     OnFileNew();
  89.                                                      
  90.     return TRUE;
  91. }
  92.  
  93. int CServerApp::ExitInstance() 
  94. {
  95.     return CWinApp::ExitInstance();
  96. }
  97.  
  98. /////////////////////////////////////////////////////////////////////////////
  99. // CAboutDlg dialog used for App About
  100.  
  101. class CAboutDlg : public CDialog
  102. {
  103. public:
  104.     CAboutDlg();
  105.  
  106. // Dialog Data
  107.     //{{AFX_DATA(CAboutDlg)
  108.     enum { IDD = IDD_ABOUTBOX };
  109.     //}}AFX_DATA
  110.  
  111. // Implementation
  112. protected:
  113.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  114.  
  115.     // Generated message map functions
  116.     //{{AFX_MSG(CAboutDlg)
  117.     virtual BOOL OnInitDialog();
  118.     //}}AFX_MSG
  119.  
  120.     DECLARE_MESSAGE_MAP()
  121. };
  122.  
  123. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  124. {
  125.     //{{AFX_DATA_INIT(CAboutDlg)
  126.     //}}AFX_DATA_INIT
  127. }
  128.  
  129. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  130. {
  131.     CDialog::DoDataExchange(pDX);
  132.     //{{AFX_DATA_MAP(CAboutDlg)
  133.     //}}AFX_DATA_MAP
  134. }
  135.  
  136. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  137.     //{{AFX_MSG_MAP(CAboutDlg)
  138.         // No message handlers
  139.     //}}AFX_MSG_MAP
  140. END_MESSAGE_MAP()
  141.  
  142. BOOL CAboutDlg::OnInitDialog() 
  143. {
  144.     CDialog::OnInitDialog();
  145.     CenterWindow();    
  146.     return TRUE; 
  147. }
  148.  
  149. // App command to run the dialog
  150. void CServerApp::OnAppAbout()
  151. {
  152.     CAboutDlg aboutDlg;
  153.     aboutDlg.DoModal();
  154. }
  155.                         
  156.